import requests
import json

# 测试创建测试用例
url = "http://127.0.0.1:5000/api/testcases"
data = {
    "name": "测试优先级功能",
    "priority": "P1",
    "description": "测试优先级字段",
    "steps": []
}

response = requests.post(url, json=data)
print("创建测试用例响应:")
print(response.status_code)
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

# 测试更新测试用例
testcase_id = response.json()['id']
update_url = f"http://127.0.0.1:5000/api/testcases/{testcase_id}"
update_data = {
    "name": "测试优先级功能-已更新",
    "priority": "P2",
    "description": "测试优先级字段更新",
    "steps": [{"action": "navigate", "value": "https://www.example.com"}]
}

response = requests.put(update_url, json=update_data)
print("\n更新测试用例响应:")
print(response.status_code)
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

# 测试获取所有测试用例
response = requests.get(url)
print("\n获取所有测试用例响应:")
print(response.status_code)
print(json.dumps(response.json(), indent=2, ensure_ascii=False))